package com.ruibang.glass.material.controller.gjs;

import com.ruibang.glass.material.domain.req.ycl.ManagementInventoryReq;
import com.ruibang.glass.material.entity.cl.MaterialCLManagementInventory;
import com.ruibang.glass.material.entity.gj.MaterialGJManagementInventory;
import com.ruibang.glass.material.entity.gjs.MaterialGJSManagementInventory;
import com.ruibang.glass.material.entity.ycl.MaterialManagementInventory;
import com.ruibang.glass.material.service.gjs.MaterialGJSManagementInventoryService;
import com.ruibang.glass.material.service.ycl.MaterialManagementInventoryService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 贵金属入库管理 前端控制器
 * </p>
 *
 * @author mameng
 * @since 2024-02-05
 */
@RestController

@RequestMapping("/api/material/gjs/management/inventory")
@Api(value="贵金属入库管理",tags={"贵金属入库管理"})
public class MaterialGJSManagementInventoryController {

    @Autowired
    private MaterialGJSManagementInventoryService materialManagementInventoryService;


    @PostMapping("/list")
    @ApiOperation(value = "贵金属入库管理列表", response = ResultBody.class)
    public ResultBody getPageList(@RequestBody ManagementInventoryReq materialManagementReq) {
        return ResultBody.success(materialManagementInventoryService.getPage(materialManagementReq));
    }

    @PostMapping("/updateById")
    @ApiOperation(value = "更新", response = ResultBody.class)
    public ResultBody updateById(@RequestBody MaterialGJSManagementInventory materialManagement) {
        materialManagementInventoryService.updateMaterialGJSManagementInventory(materialManagement);
        return ResultBody.success();
    }

    @PostMapping("/updateStatusById")
    @ApiOperation(value = "贵金属入库更改状态", response = ResultBody.class)
    public ResultBody updateStatusById(@RequestBody MaterialGJSManagementInventory materialManagement) {
        materialManagementInventoryService.updateStatusById(materialManagement);
        return ResultBody.success();
    }

    @PostMapping("/add")
    @ApiOperation(value = "工具入库新增", response = ResultBody.class)
    public ResultBody add(@RequestBody MaterialGJSManagementInventory materialManagement) {
        return ResultBody.success(materialManagementInventoryService.saveMaterialManagementInventory(materialManagement));
    }


    @GetMapping("/getOne/{id}")
    @ApiOperation(value = "工具入库详情", response = ResultBody.class)
    public ResultBody getOne(@PathVariable("id") String id) {
        return ResultBody.success(materialManagementInventoryService.getDetail(id));
    }

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "详情", response = ResultBody.class)
    public ResultBody getById(@PathVariable("id") String id) {
        return ResultBody.success(materialManagementInventoryService.getDetail(id));
    }

    @PostMapping("/deleteList")
    @ApiOperation(value = "批量删除", response = ResultBody.class)
    public ResultBody deleteList(@RequestBody MaterialGJSManagementInventory materialManagement) {
        return ResultBody.success(materialManagementInventoryService.removeBatchByIds(materialManagement.getIds()));
    }

    @PostMapping("/updateInHouse")
    @ApiOperation(value = "完成入库", response = ResultBody.class)
    public ResultBody updateInHouse(@RequestBody MaterialGJSManagementInventory materialManagement) {
        materialManagementInventoryService.updateInHouse(materialManagement);
        return ResultBody.success();
    }




}
